<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Common\Model;

/**
 * Description of MemberLvModel
 *
 * @author gangguo
 */
class MemberLvModel extends XuecheModel{
    //put your code here

    protected $pk = 'member_lv_id';
    protected $tableName = 'member_lv';
    protected $fields = array(
            'member_lv_id','name','lv_logo','pre_id', 'default_lv','lv_type','point',
            'disabled','lv_remark','tj_nums','shelf_nums'
        );


    public function Validate($data) {
        if(!empty($data['point']) && strlen($data['point']) > 8){
            return FALSE;
        }
        return TRUE;
    }

    public function getMemberLv($point){
        if(is_numeric($point)){
            return $this->where("`point` <= '{$point}'")->order("point desc")->find();
        }
    }

    //批量或单个删除数据
    public function delLv($ids){
        if(empty($ids)){
            return FALSE;
        }
        if(is_numeric($ida)){
            return $this->delete($ids);
        }
        $ida = explode(',', $ids);
        if(is_array($ida)){
            foreach ($ida as $v){
                if(!is_numeric($v) || empty($v)){
                    return FALSE;
                }
            }
            return $this->delete($ids);
        }

    }


}
